﻿/*
 * File: BattlegroundTopMenuScene.cs
 * Author: Gourav Das
 * Purpose: Load and show Battleground menu scene
 * Created: May 01 2011
 * Copyright: Gourav Das, 2011
 */

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using _22yards._2D;
using _22yards.Scenes.Helpers;
using _22yards.EnumDeclarations;

namespace _22yards.Scenes
{
    class TopBattlegroundMenuScene : BaseMenuScene
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TopBattlegroundMenuScene"/> class.
        /// </summary>
        public TopBattlegroundMenuScene()
            : base("Battleground")
        {
            // Create our menu Items.
            MenuItem StreetCricketMenuItem = new MenuItem("Street Cricket - Not implemented",0);
            MenuItem ParkCricketMenuItem = new MenuItem("Park Cricket - Not implemented",1);
            MenuItem DomesticCricketMenuItem = new MenuItem("Domestic Cricket - Not implemented",2);
            MenuItem InternationalCricketItem = new MenuItem("International Cricket",3);
            MenuItem BackMenuEntry = new MenuItem("Back",4,true);


            // Hook up menu event handlers.
            StreetCricketMenuItem.Selected += StreetCricketMenuItem_Selected;
            ParkCricketMenuItem.Selected += ParkCricketMenuItem_Selected;
            DomesticCricketMenuItem.Selected += DomesticCricketMenuItem_Selected;
            InternationalCricketItem.Selected += InternationalCricketItem_Selected;
            BackMenuEntry.Selected += BackMenuEntry_Selected;

            // Add Items to the menu.
            MenuItems.Add(StreetCricketMenuItem);
            MenuItems.Add(ParkCricketMenuItem);
            MenuItems.Add(DomesticCricketMenuItem);
            MenuItems.Add(InternationalCricketItem);
            MenuItems.Add(BackMenuEntry);
        }

        ~TopBattlegroundMenuScene()
        {
            ExitScene();
        }

        /// <summary>
        /// Event handler for when the StreetCricketMenuItem is Selected.
        /// </summary>
        void StreetCricketMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            Game22Yards.match.TypeOfMatch = (int)MatchType.streetMatchLimited - ((int)MatchType.streetMatchLimited % 30);
            const string msg = "Please be patient, will be implementing soon!!";

            MsgBoxScreen confirmExitMsgBox = new MsgBoxScreen(msg);
            confirmExitMsgBox.Accepted += OnCancel;

            sceneEngine.AddScene(confirmExitMsgBox, e.PlayerIndex);
        }

        /// <summary>
        /// Event handler for when the ParkCricketMenuItem is selected.
        /// </summary>
        void ParkCricketMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            Game22Yards.match.TypeOfMatch = (int)MatchType.ParkMatchLimited - ((int)MatchType.ParkMatchLimited % 30);
            const string msg = "Please be patient, will be implementing soon!!";

            MsgBoxScreen confirmExitMsgBox = new MsgBoxScreen(msg);
            confirmExitMsgBox.Accepted += OnCancel;

            sceneEngine.AddScene(confirmExitMsgBox, e.PlayerIndex);
        }

        /// <summary>
        /// Event handler for when the DomesticCricketMenuItem is selected.
        /// </summary>
        void DomesticCricketMenuItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            Game22Yards.match.TypeOfMatch = (int)MatchType.FirstClassT20 - ((int)MatchType.FirstClassT20 % 20);
            const string msg = "Please be patient, will be implementing soon!!";

            MsgBoxScreen confirmExitMsgBox = new MsgBoxScreen(msg);
            confirmExitMsgBox.Accepted += OnCancel;

            sceneEngine.AddScene(confirmExitMsgBox, e.PlayerIndex);
        }


        /// <summary>
        /// Event handler for when the InternationalCricketItem is selected.
        /// </summary>
        void InternationalCricketItem_Selected(object sender, PlayerIndexEventArgs e)
        {
            //Set base type of match. set 10
            Game22Yards.match.TypeOfMatch = (int)MatchType.OneDayInternational - ((int)MatchType.OneDayInternational % 10);
            ExitScene();
            sceneEngine.AddScene(new BottomBattlegroundMenuScene("International Cricket"), e.PlayerIndex);
        }

        /// <summary>
        /// Event handler for when the BackMenuEntry is selected.
        /// </summary>
        void BackMenuEntry_Selected(object sender, PlayerIndexEventArgs e)
        {
            ExitScene();
            sceneEngine.AddScene(new MainMenuScene(), e.PlayerIndex);
            //sceneEngine.RemoveScene(this);
        }

        /// <summary>
        /// When the user presses ESC, do nothing.
        /// </summary>
        protected override void OnCancel(PlayerIndex _playerIndex)
        {
            //Do nothing :)
        }
    }

}
